package club.itstudio.itouc.controller.jw.course

import club.itstudio.itouc.core.util.Result
import club.itstudio.itouc.core.util.ResultUtil
import club.itstudio.itouc.entity.CourseType
import club.itstudio.itouc.util.Mysql
import club.itstudio.itouc.util.Redis
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RestController

/**
 * 通过课程类型获取课表
 */
@RestController
class ListByType (val redis: Redis,
                  val mysql: Mysql){
    @GetMapping("/jw/course/{courseType}")
    fun listByType(@PathVariable courseType: CourseType): Result<Any>{
        val classNumList = mysql.getCourseListByType(courseType)
        val courseList = redis.getCourseList(classNumList)
        return ResultUtil.success(courseList)
    }
}